package com.seek.oss.controller;

import com.seek.commonutils.ResponseResult;
import com.seek.oss.service.OssService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * author wml
 * Created on 2022/1/13 12:20
 */
@RestController
@RequestMapping("/eduoss/file-oss")
public class OssController {

    @Autowired
    private OssService ossService;

    // 上传头像到 oss 的方法
    @PostMapping
    public ResponseResult uploadOssFile(MultipartFile file) {
        // 获取上传文件
        // 返回上传到 oss 的路径
        String url = ossService.uploadFileAvatar(file);
        return ResponseResult.ok().data("url", url);
    }
}
